<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="hexinyang">
		<title>黑名单管理</title>
		<script language="javascript" type="text/javascript" src="../script/common.js"></script>
		<script language="javascript" type="text/javascript">
			//数据表格对象
			var qt = {};
			//页面加载方法				
			function load(){
				Eui.showNavigation();
				Common.initDict(searchForm.cardType,"base_card_type","全 部");         //初始化字典
				Eui.initBeginDateInput("beginDateTd","起始添加日期","searchForm","addDateStart","addDateEnd","_pastDate");	//初始化起始添加日期
				Eui.initEndDateInput("endDateTd","结束添加日期","searchForm","addDateStart","addDateEnd","_pastDate");	  	//初始化结束添加日期	
				setPages(["listview","detview","partview"])							
				createTable();			
			}
			//生成表格，创建QueryTable对象
			function createTable(){
				var columns = [];					
				columns[0]={type:"checkbox"};
				qt = new QueryTable("black","searchForm","datalist",columns,{
					buttons:[
						{value:"增 加",actions:onNew},
						{value:"删 除",actions:onDelete}
					]
				});
			}
			//显示、刷新表格
			function showData(){	
				qt.showTable();									//qt为全局的QueryTable对象
			}
			//删除黑名单方法
			function onDelete(){					
				var ids = qt.getBoxValue(); //获得操作对象的id
				if(!ids){
					showWarning("请选择需要删除的卡号。");
					return;
				}
				if(showQuestion("是否确认删除")){
					DWR.call("blacklistService.adminUnlockCard",ids,function(){
						showInformation("删除成功.");            //提示信息
						showData();							    //刷新表格
					},{disCtrl:$("delBtn")});
				}
			}
			//显示新增界面
			function onNew(){
				blackform.reset();                  	 //重置表单
				switchPage("detview");               	 //跳转到新增页面
			}
			//数据保存
			function onBlack(){
				var asn=addform.asn.value;
				DWR.call("blacklistService.adminLockCard",asn,"",function(){
					showInformation("添加成功.");     	//提示信息
					addform.reset();			
					switchPage("listview");				//跳转到表格页面
					showData();							//刷新表格
				},{disCtrl:blackform.blackBtn});	//限制按扭重复点击
			}
			//根据卡号查询卡明细 
			function refer(){
				if(!checkForm(addform))return;
				var asn= addform.asn.value;		
				DWR.call("cardMgntService.cardSearch",asn,function(res){
					var card = res.card;
					if (card.status != CardStatus.OK && (card.status != CardStatus.BLACK || (card.blackType != MgntOtherConstant.CARD_BLACKTYPE_OFFICIAL && card.blackType != MgntOtherConstant.CARD_BLACKTYPE_TEMP))){
						showWarning("卡片为"+Common.getText(CardStatus.CATEGORY,card.status)+"状态，不能执行此操作！");return;
					}
					if (card.storeStatus != CardStoreStatus.IN_USE){
						showWarning("卡片为"+Common.getText(CardStoreStatus.CATEGORY,card.storeStatus)+"状态，不能执行此操作!");return;
					}
					if(res.card.baseCardType==BaseCardType.PSAM){
						showError("psam卡不能执行此操作！");
						return;
					}
					if(res.card.baseCardType==BaseCardType.OPERATOR){
						showError("操作员卡不能执行此操作！");
						return;
					}
					res.asn = res.card.asn;
					res.cardType = Common.getText("base_card_type",res.cardType.baseCardType);        //转换卡类型字典
					res.cardStatus = Common.getText("card_status",res.card.status);	//转换卡状态字典
					var balance = res.accounts.card_1?res.accounts.card_1.balance:0
					res.balance = Format.fenToYuan(balance)
					var loyaltyBalance = res.accounts.card_2?res.accounts.card_2.balance:0
					res.loyaltyBalance = Format.fenToYuan(loyaltyBalance);
					res.idno = res.customer?res.customer.idno:"";
					Common.showDetail("blackform",res);                               //加载查询信息
					switchPage("partview");				//跳转到表格页面										//显示明细
				},{disCtrl:addform.selBtn});										//限制按扭重复点击
			}		
			//取消
			function cancel(){
				addform.reset();                             //重置表单
				switchPage("detview");						 //跳转页面
			}
			function sel(){
				var time = searchForm.addDateEnd.value;         //操作日期
				if(time){												 //如果存在操作日期将日期限制在当天
					var arrtime =time.split("-");
					var todaytime = new Date(arrtime[0],arrtime[1]-1,arrtime[2]);
					todaytime.setDate(todaytime.getDate()+1);
					searchForm.dateEnd.value = todaytime.format();
				}else{
					searchForm.dateEnd.value = "";
				}
				qt.showTable();										 //刷新表格
			}
		</script>
	</head>	
	<body onload="load()">
		<!--页面导航-->
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="listview">	
			<!--查询条件form-->
			<div class="searchForm">
				<form id="searchForm" name="searchForm">
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label6">
					<tr>
						<td><label>卡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</label> <input type="text" name="asn" onBlur="checkV(this,'asn')"></td>
						<td id="beginDateTd"></td>
						<td><label>卡片类型</label> <select name="cardType"><option></option></select></td>
					</tr>
					<tr>
						<td><label>客户证件号</label> <input type="text" name="idno" onBlur="checkV(this,'99')" ></td>
						<td id="endDateTd"></td>
						<td><input type="hidden" name = "dateEnd"><button type="button" onClick="sel()">查 询</button></td>
					</tr>
				</table>
				</form>
			</div>
			<div id="datalist"></div>	<!--查询结构列表-->		
			<div class="listBorder" id="blickborder" style="display:none;">
				<div class="listBar">
					<div class="listTitle">黑名单列表</div>
					<div class="listBtn" id="listBtn">
						<button type="button" onClick="onNew()">增 加</button>
						<button type="button" onClick="onDelete()" id="delBtn">删 除</button>
					</div>
				</div>				
			</div>
		</div>
		<!--(新增)查询部分-->
		<div id="detview" style="display:none;">
			<form id="addform" name="addform" class="label4">
				<div class="form">
					<div class="formTitle">请输入预冻结的卡号</div>
					<table cellSpacing="0" cellPadding="4" width="100%" border="0">
						<tr>
							<td><label>卡号</label> <input type="text" name="asn" onBlur="checkV(this,'asn',true)"><span class="des">*</span></td>
							<td>
								&nbsp;
							</td>
						</tr>	
					</table>
				</div>
			</form>
			<p>
				<button type="button" name="selBtn" onclick="refer()">查 询</button>
				<button type="button" onclick="switchPage('listview');">返 回</button>
			</p>
		</div>
		<!--显示人员信息-->
		<div id="partview" style="display:none;">
			<form id="blackform" name="blackform" class="label5 viewTable">
				<div class="form">
					<div class="formTitle">卡明细</div>
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable">
						<tr>
							<td><label>卡&nbsp;&nbsp;&nbsp;&nbsp;号</label> <span id="asn"></span></td>
							<td><label>客户证件号</label> <span id="idno"></span></td>
						</tr>
						<tr>
							<td><label>卡&nbsp;类&nbsp;型 </label> <span id="cardType"></span></td>
							<td><label>卡&nbsp;状&nbsp;态 </label> <span id="cardStatus"></span></td>															
						</tr>
						<tr>
							<td><label>余&nbsp;&nbsp;&nbsp;&nbsp;额</label> <span id="balance"></span> 元</td>
							<td><label>积分余额</label> <span id="loyaltyBalance"></span> 元</td>
						</tr>
					</table>
				</div>	
				<p>
					<button type="button" onclick="onBlack()" name="blackBtn">加入黑名单</button>
					<button type="button" onClick="cancel()">取 消</button>
				</p>
			</form>
		</div>
	</body>
</html>
